
cmake_minimum_required(VERSION 3.4.1)

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.


add_definitions(
        -fsigned-char    #ARM平台下注意char 默认是无符号的，需要启用此定义
        -DLONS_DEBUG     #debug标记s

        -DSDL_JAVA_PACKAGE_PATH=com_xc_lons
        -DLINUX
        -DUSE_LUA
)

#include_directories(../androidlua/lua)
#include_directories(../bz2/include)
include_directories(../../SDL2_image-2.0.5)
include_directories(../../SDL2_ttf-2.0.15)
include_directories(../../SDL2_mixer-2.0.4)
include_directories(../../SDL2-2.0.12/include)

set(MY_LIBS_NAME "app_ONS_LONS")

if(${MY_STATIC_LIBS} MATCHES "#${MY_LIBS_NAME}#")
    set(IS_LIBS_STATIC STATIC)
    message("${MY_LIBS_NAME} will be STATIC")
else()
    set(IS_LIBS_STATIC SHARED)
endif()

set(SRCFILES1
        src/BinArray.cpp
        src/Global.cpp
        src/LOAnimation.cpp
        src/LOCodePage.cpp
        src/LOEffect.cpp
        src/LOEvent.cpp
        src/LOFontBase.cpp
        src/LOFontInfo.cpp
        #src/LOGLrender.cpp
        src/LOLayer.cpp
        src/LOLayerInfo.cpp
        src/LOLayerInfoCache.cpp
        src/LOMatrix2d.cpp
        LONS_main.cpp
        src/LOprint.cpp
        src/LOSave.cpp
        src/LOShader.cpp
        #src/LORender.cpp
        #src/LOTheard.cpp
        src/ONScripter.cpp
        src/ONScripter_command.cpp
        src/ONScripter_commandSC.cpp
        src/ONScripter_lut.cpp
        src/ONScripter_rmenu.cpp
        src/ONScripter_script.cpp
        src/ONScripterAudio.cpp
        src/ONScripterFile.cpp
        src/ONScripterImage.cpp
		src/ONScripterImage2.cpp
        src/ONScripterScript.cpp
        src/ONSvariable.cpp
        )

add_library( # Sets the name of the library.
        ${MY_LIBS_NAME}

        # Sets the library as a shared library.
        ${IS_LIBS_STATIC}
        # Provides a relative path to your source file(s).
        ${SRCFILES1}
        )

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
        log-lib
        #lua
        #bz2
        SDL2_image
        SDL2_mixer
        SDL2_ttf
        SDL2
        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
        ${MY_LIBS_NAME}
        #lua
        #bz2
        SDL2_image
        SDL2_mixer
        SDL2_ttf
        SDL2
        ###
        #GLESv1_CM
        GLESv2
        #dl
        # Links the target library to the log library
        # included in the NDK.
        ${log-lib})